package com.linglan.common.utils;

import cn.hutool.core.util.IdUtil;
import com.linglan.common.config.PrimaryKeyConfig;
import com.linglan.common.handler.SpringContextHolder;

/**
 * 主键生成器
 */
public class PrimaryKeyUtil {

    private static final PrimaryKeyConfig primaryKeyProperties = SpringContextHolder.getBean(PrimaryKeyConfig.class);

    public static long getId() {
        return IdUtil.getSnowflake(primaryKeyProperties.getWorkerId(), primaryKeyProperties.getDatacenterId()).nextId();
    }
}
